<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<c:set var="uri" value="${pageContext.request.contextPath}" />
    
    <script type="text/javascript">
    var uri='${uri}';
        </script>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>修改-攻略</title>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/layui/css/layui.css">
            
            <style type="text/css">
            
            .loadingModel {
                position: absolute;
                top: 0;
                left: 0;
                display: none;
                background-color: rgba(9, 9, 9, 0.63);
                width: 100%;
                height: 100%;
                z-index: 1000;
            }
            .loading-content {
                width: 50%;
                text-align: center;
                background: #ffffff;
                border-radius: 6px;
                line-height: 30px;
                z-index: 10001;
            }
            </style>
            </head>
            <div id="loadingDiv"></div>
            <div id="imgModal"></div>
            <div class="layui-container" style="overflow:hidden;height:2000px">
            <div class="layui-row">
            <div class="layui-col-lg12">
            <fieldset class="layui-elem-field">
            <legend>修改-攻略</legend>
            <div class="layui-field-box">
            <div >
            
            
            <div class="layui-form-item layui-form-text" id="titleParentContent">
            <label class="layui-form-label">攻略标题</label>
            <div class="layui-input-block">
            <input type="text"  style="width:500px;display:inline" value="${data.title}" placeholder="请输入攻略标题" id="title" class="layui-input">	<span style="color:red">*必填</span>
                
                </div>
                </div>
                
                <div class="layui-form-item layui-form-text" id="contentParentContent">
                <label class="layui-form-label">攻略文章</label>
                <div class="layui-input-block">
                <div id="contentDiv1" data-id="content"  class="toolbar" style="margin-top:3%;"></div>
                <div id="contentDiv2"  class="text" style="min-height:300px;z-index:1"></div>
                <span style="color:red">*必填</span>
                
                </div>
                </div>
                
                <div class="layui-form-item layui-form-text" id="glTypeParentContent">
                <label class="layui-form-label">所属板块</label>
                <div class="layui-input-block">
                <select  id="glType" style="height:30px;width:500px;display:inline" >
                <c:forEach items="${typeInfoList}" var="item">
                    <c:if test="${item.id==data.glType}">
                        <option value="${item.id}" selected>${item.name}</option>
                            </c:if>
                            <c:if test="${item.id!=data.glType}">
                                <option value="${item.id}">${item.name}</option>
                                    </c:if>
                                    </c:forEach>
                                    </select>
                                    <span style="color:red">*必填</span>
                                    
                                    </div>
                                    </div>
                                    
                                    <div class="layui-form-item layui-form-text" id="glLevelParentContent">
                                    <label class="layui-form-label">观看级别</label>
                                    <div class="layui-input-block">
                                    <select  id="glLevel" style="height:30px;width:500px;display:inline" >
                                    <c:forEach items="${glLevelList}" var="item">
                                        <c:if test="${item.id==data.glLevel}">
                                            <option value="${item.id}" selected>${item.name}</option>
                                                </c:if>
                                                <c:if test="${item.id!=data.glLevel}">
                                                    <option value="${item.id}">${item.name}</option>
                                                        </c:if>
                                                        </c:forEach>
                                                        </select>
                                                        <span style="color:red">*必填</span>
                                                        
                                                        </div>
                                                        </div>
                                                        
                                                        <div class="layui-form-item">
                                                        <div class="layui-input-block">
                                                        <button class="layui-btn" onclick="submitData();" >立即提交</button>
                                                        <button  class="layui-btn layui-btn-primary"  onclick="javascript:history.back(-1);" >返回</button>
                                                        </div>
                                                        </div>
                                                        </div>
                                                        </div>
                                                        </fieldset>
                                                        </div>
                                                        </div>
                                                        </div>
                                                        <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/jquery-1.11.1.min.js"></script>
                                                            
                                                            
                                                            <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/wangeditor-3.0.17/wangEditor.min.js"></script>
                                                                <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/wangeditor-3.0.17/wangeditor_emotion.js"></script>
                                                                    
                                                                    
                                                                    
                                                                    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui/layui.js"></script>
                                                                        <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/utils/listutils.js?v=3075"></script>
                                                                            
                                                                            <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/common/selectSearch/jquery.searchableSelect.css?d=129339" />
                                                                                <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/selectSearch/jquery.searchableSelect.js?d=1293393"></script>
                                                                                    
                                                                                    
                                                                                    <script type="text/javascript">
                                                                                    
                                                                                    
                                                                                    var wangList=[];
                                                                                    
                                                                                    $(function(){
                                                                                        
                                                                                        var contentMap = {};
                                                                                            var contentEdit =window.wangEditor;
                                                                                            editor = new contentEdit('#contentDiv1', '#contentDiv2');
                                                                                            editor.customConfig.uploadImgServer = '${pageContext.request.contextPath}/commonapi/imgUpload/imgUploadForWangEditor'
                                                                                                editor.customConfig.uploadImgMaxSize = 3 * 1024 * 1024;
                                                                                                editor.customConfig.uploadImgMaxLength = 5;
                                                                                                editor.customConfig.uploadImgTimeout = 30000;
                                                                                                editor.customConfig.uploadFileName = 'files'
                                                                                                editor.customConfig.emotions = [{ title: '默认',type: 'image',content:wangeditorEmotions}];
                                                                                                    editor.create();
                                                                                                    $('#contentDiv2').css("z-index","1");
                                                                                                    contentMap.id='content';
                                                                                                    contentMap.edit=editor;
                                                                                                    wangList.push(contentMap);
                                                                                                    editor.txt.html(getData().content);
                                                                                                    $('#glType').next().remove();
                                                                                                    $('#glType').searchableSelect();
                                                                                                    
                                                                                                    
                                                                                                })
                                                                                                
                                                                                                
                                                                                                
                                                                                                function getEditVal(name){
                                                                                                    for(var i=0;i<wangList.length;i++){
                                                                                                        var dataId = wangList[i].id;
                                                                                                        if(dataId==name){
                                                                                                            return wangList[i].edit.txt.html();
                                                                                                        }
                                                                                                    }
                                                                                                    return '';
                                                                                                }
                                                                                                function getData(){
                                                                                                    var data={};
                                                                                                        $.ajax({
                                                                                                            async:false,
                                                                                                            type: 'post',
                                                                                                            url: '${pageContext.request.contextPath}/user/gl_info/queryDataDetail',
                                                                                                                data:{
                                                                                                                    "id":'${data.id}'
                                                                                                                    },
                                                                                                                    success: function(result) {
                                                                                                                        data = result;
                                                                                                                    }
                                                                                                                });
                                                                                                                return data;
                                                                                                            }
                                                                                                            function submitData(){
                                                                                                                var title= $('#title').val();
                                                                                                                var content=getEditVal('content');
                                                                                                                var glType= $('#glType').val();
                                                                                                                var glLevel= $('#glLevel').val();
                                                                                                                
                                                                                                                $.ajax({
                                                                                                                    type: 'post',
                                                                                                                    url: '${pageContext.request.contextPath}/user/gl_info/update_submit',
                                                                                                                        data:{
                                                                                                                            "id":'${data.id}',
                                                                                                                                "title":title,
                                                                                                                                "content":content,
                                                                                                                                "glType":glType,
                                                                                                                                "glLevel":glLevel
                                                                                                                            },
                                                                                                                            success: function(result) {
                                                                                                                                if(result.code == 0){
                                                                                                                                    alert(result.msg);
                                                                                                                                    }else{
                                                                                                                                        alert(result.msg);
                                                                                                                                        self.location=document.referrer;
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            });
                                                                                                                        }
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        </script>
                                                                                                                        </body>
                                                                                                                        </html>
